<template>
  <Layout desc="使用scroll-snap实现滚动吸附效果">
    <div class="mt-20 wrapper">
      <div class="card" v-for="item in 5">
        <h2>{{ item }}</h2>
      </div>
    </div>
  </Layout>
</template>

<script setup lang="ts"></script>

<style scoped lang="scss">
.wrapper {
  display: flex;
  gap: 20px;
  width: 300px;
  height: 400px;
  background-color: #f7f7f7;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  border-radius: 14px;

  overflow-x: scroll;
  scroll-snap-type: x mandatory;
}

.card {
  scroll-snap-align: center;

  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 300px;
  background-color: #fff;
  border-radius: 14px;
  font-size: 48px;
}
</style>
